package com.ax.base.common.dao;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.ax.base.common.domain.BaseHint;

@Mapper
public interface BaseHintMapper {

	/**
     * 查询所有提示
     *
     * @param Map<String, Object> map
     *
     * @return List<BaseHint>
     */
	@Select("<script>"+
            "select "+
            "Hint_ID , Area_Code, Area_Name , Hint_Content, create_date , update_date,Flag "+
            "from base_hint"+
            "<where>" +
            "<if test=\"hintId!=null\">"+"and Hint_ID=#{hintId}"+"</if>"+
            "</where>"+
            "</script>")
	List<BaseHint> queryBaseHintMapper(Map<String, Object> params);
	
	/**
	 * 提示配置详情(修改)
	 * 
	 * @param Long hintId
	 *           
	 * @return BaseHint baseHints
	 */
	@Select("<script>"+
            "select "+
            "Hint_ID , Area_Code, Area_Name , Hint_Content, create_date , update_date,Flag "+
            "from base_hint"+
            "<where>" +
            "<if test=\"hintId!=null\">"+"and Hint_ID=#{hintId}"+"</if>"+
            "</where>"+
            "</script>")
	BaseHint getBaseHintMapper(@Param("hintId") Long hintId);
	
	/**
     * 添加充值规则
     * 
     * @param BaseHint baseHint
     * 
     * @return SUCC
     */
	@Insert("<script>"+
            "insert into base_hint (Hint_ID, Area_Code, Area_Name,"+
            "Hint_Content, create_date, update_date,Flag "+
            ")"+
            "values (#{hintId}, #{areaCode}, #{areaName},"+
            "#{hintContent},NOW(), #{updateDate},#{flag}"+
            ")"+
            "</script>")
	void insertBaseHintMapper(BaseHint baseHint);
	
	/**
     * 修改配置详情
     * 
     * @param BaseHint baseHint
     * 
     * @return SUCC
     */
	@Update("<script>"+
	            "update base_hint"+
	            "<set>"+
	            "<if test=\"areaCode != null and areaCode != ''\">"+ " Area_Code= #{areaCode}," + "</if>" +
	            "<if test=\"areaName != null and areaName != ''\">"+ "Area_Name = #{areaName}," + "</if>" +
	            "<if test=\"hintContent != null and hintContent != null\">"+ "Hint_Content = #{hintContent}," + "</if>" +
	            "<if test=\"createDate != null\">"+ "create_date = #{createDate}," + "</if>" +
	            "update_date = NOW()," +
	            "<if test=\"flag != null\">"+ "Flag = #{flag}," + "</if>" +
	            "</set>"+
	            "<where>"+
	            "Hint_ID = #{hintId}"  +
	            "</where>"+
	            "</script>" )
	void updateBaseHintMapper(BaseHint baseHint);
	
}
